#include "xmpptask.h"
#include "taskmanager.h"
#include <sstream>

namespace tinkle {

XmppTask::XmppTask(BaseTask *parent)
    : Task(parent) {
}

XmppTask::~XmppTask() {

}

bool XmppTask::HasNetworkEvent() const {
    return true;
}

std::string XmppTask::GenSessionId() {
    static uint32_t sessionId = 1;
    std::stringstream strId;
    strId << sessionId;
    if (sessionId == 0xFFFFFFFF) {
        sessionId = 1;
    } else {
        sessionId++;
    }
    return strId.str();
}

bool XmppTask::NextStanza(XmlNode *stanza) {
    return false;
}

void XmppTask::SendStanza(XmlNode *stanza) {
    GetManager()->GetStanzaManager()->Write(stanza);
}

void XmppTask::SendStanza(const std::string &stanzaStr) {
    GetManager()->GetStanzaManager()->Write(stanzaStr);
}

}